﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AudioDemo.View
{
    /// <summary>
    /// text2.xaml 的交互逻辑
    /// </summary>
    public partial class text2 : Window
    {
        public text2()
        {
            InitializeComponent();

            richTextBox.Document = doc;

            //添加内容
            append(Brushes.Red, "张三丰");
            append(Brushes.Blue, "张无忌");
        }
        FlowDocument doc = new FlowDocument();
        private void append(Brush brush, string txt)
        {
            Paragraph p = new Paragraph();
            var r = new Run(txt);
            p.Inlines.Add(r);
            p.Foreground = brush;
            doc.Blocks.Add(p);
        }

    }
}
